var Financing = function () {};

Financing.prototype = {
    init: function () {},
    set: function (obj) {
        var defaultData = JSON.parse(LocalContractStorage.get('all'));
        var data = Object.prototype.toString.call(defaultData) == '[object Array]' ? defaultData : [];
        data.push({
            id: obj.id,
            industry: obj.industry,
            release_type: obj.release_type,
            industry_details: obj.industry_details,
            keyword: obj.keyword,
            author: obj.author,
            contact: obj.contact,
            content: obj.content,
            matchObj:[]
          
        });
         for (var i = 0; i < data.length-1; i++) {
            if ((data[i].keyword == obj.keyword) && (data[i].release_type != obj.release_type)) {
                data[i].matchObj.push({
                    id: obj.id,
                    industry: obj.industry,
                    release_type: obj.release_type,
                    industry_details: obj.industry_details,
                    keyword: obj.keyword,
                    author: obj.author,
                    contact: obj.contact,
                    content: obj.content,
                    matchObj:[]
                });
            }
        }
        if (data.length > 1) {
            LocalContractStorage.del('all');
        };
        LocalContractStorage.set('all', JSON.stringify(data));
    },
    get: function () {
        return LocalContractStorage.get('all');
    },
    // 匹配需求
    // matching:function(keyword,release_type){
    // 	//当前所处行数
    // 	var sorted = true;
    // 	var data = JSON.parse(LocalContractStorage.get('all'));
    //     for (var i = 0; i < data.length-1; i++) {
    //     	sorted = true;
    //     	for (var i = 0; i < Things.length-1-j; i++) {
    //     		if (data[j].keyword == data[i].keyword && data[j].id != data[i].id) {
    //     			data[j].matchObj.push({
    //     				id: data[i].id,
			 //            industry: data[i].industry,
			 //            release_type: data[i].release_type,
			 //            industry_details: data[i].industry_details,
			 //            keyword: data[i].keyword,
			 //            author: data[i].author,
			 //            contact: data[i].contact,
			 //            content: data[i].content,
			 //            matchObj:[]
    //     			});
    //     			sorted = false;
    //     		}
    //     	}
    //     	if (sorted = true) {
    //     		break;
    //     	} 	
    //     }
    //     LocalContractStorage.del('all');
    //     LocalContractStorage.set('all', JSON.stringify(data));
    // },
};

module.exports = Financing;
